﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _06_委托练习
{
    public partial class Frm_JopMove : Form
    {
        public Frm_JopMove(Action<bool> action)
        {
            InitializeComponent();
            //上
            this.btnUp.MouseDown += (sender, e) => MainForm.SetPointState(PointState.Up);
            this.btnUp.MouseUp += (sender, e) => MainForm.SetPointState(PointState.None);
            //下
            this.btnDown.MouseDown += (sender, e) => MainForm.SetPointState(PointState.Down);
            this.btnDown.MouseUp += (sender, e) => MainForm.SetPointState(PointState.None);
            //左
            this.btnLeft.MouseDown += (sender, e) => MainForm.SetPointState(PointState.Left);
            this.btnLeft.MouseUp += (sender, e) => MainForm.SetPointState(PointState.None);
            //右
            this.btnRight.MouseDown += (sender, e) => MainForm.SetPointState(PointState.Right);
            this.btnRight.MouseUp += (sender, e) => MainForm.SetPointState(PointState.None);
            //关闭窗体-响应事件
            this.FormClosed += (sender, e) => action(true);
        }
    }
}
